package controllers.participant;

import java.util.Collection;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import services.AssessService;
import services.ParticipantService;
import controllers.AbstractController;
import domain.Assess;

@Controller
@RequestMapping("/route/participant/assess")
public class AssessRouteParticipantController extends AbstractController {
	
	
	@Autowired
	private AssessService assessService;
	@Autowired
	private ParticipantService participantService;

	public AssessRouteParticipantController() {
		super();
	}
	//Listing
	@RequestMapping(value = "/list", method = RequestMethod.GET)
	public ModelAndView list() {
		ModelAndView result;
		Collection<Assess> assessments;
		assessments = assessService.findByParticipantId(participantService.findByPrincipal().getId());
		result = new ModelAndView("assess/list");
		result.addObject("requestURI", "route/participant/list.do");
		result.addObject("assessments", assessments);
		return result;
	}
}
